package org.ihelpuoo.weboo.module;

import org.ihelpuoo.lang.StringUtils;
import org.ihelpuoo.orm.filter.CharFieldFilter;
import org.ihelpuoo.orm.filter.FieldFilter;
import org.ihelpuoo.util.ValueSet;
import org.ihelpuoo.weboo.Weboo;

public class ActionProperties extends ValueSet
{

	private ActionConfig	config;

	ActionProperties(ActionConfig config)
	{
		this.config = config;
	}

	@Override
	public Object get(String key)
	{
		return config.getPropertyValue(key);
	}

	public FieldFilter getFieldFilter(String key)
	{
		CharFieldFilter af = null;
		String s = config.getPropertyValue(key);
		if (!StringUtils.isBlank(s))
			af = new CharFieldFilter(s);
		return af;
	}

	public FieldFilter getPrintActivedFieldFilter()
	{
		return getFieldFilter(Weboo.FF_PRINT_ACTIVED);
	}

	public FieldFilter getPrintLockedFieldFilter()
	{
		return getFieldFilter(Weboo.FF_PRINT_LOCKED);
	}

	public FieldFilter getDBIOActivedFieldFilter()
	{
		return getFieldFilter(Weboo.FF_DBIO_ACTIVED);
	}

	public FieldFilter getDBIOLockedFieldFilter()
	{
		return getFieldFilter(Weboo.FF_DBIO_LOCKED);
	}

	public Class getAsClass(String name) throws ClassNotFoundException
	{
		String klass = this.getStringTrimed(name);
		if (klass == null)
			throw new ClassNotFoundException("NULL");
		return Class.forName(klass);
	}

	public Class getObjectType() throws ClassNotFoundException
	{
		return getAsClass(Weboo.OBJECT_TYPE);
	}

}
